import datetime
import uuid

from rest_framework import serializers
from apps.models import Order, HouseKeeping, OrderDetail, Address
from apps.utils.common_function import get_timestamp
from apps.utils.common_response import APIResponse


class OrderSerializer(serializers.ModelSerializer):
    # username = serializers.ReadOnlyField(source='user.username')
    title = serializers.ReadOnlyField(source='housekeeping.title')
    price = serializers.ReadOnlyField(source='housekeeping.price')
    cover = serializers.FileField(source='housekeeping.cover', required=False)
    order_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S', required=False)

    class Meta:
        model = Order
        # fields = ['title', 'price', 'cover',
        #           'count', 'out_trade_no', 'order_time']
        fields = '__all__'


class OrderDetailSerializer(serializers.ModelSerializer):
    class Meta:
        model = OrderDetail
        fields='__all__'


